home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MIDICraft's MIDINET CD-ROM
/
MIDICraft's MIDINET CD-ROM.iso
/
DOSUTILS
/
MIDIFIX.ZIP
/
MIDIFIX.DOC
< prev
next >
Wrap
Text File
|
1996-09-16
|
7KB
|
167 lines
******************************
MIDIFIX v1.4
fix midi structure errors
by Guenter Nagler
1995
(gnagler@ihm.tu-graz.ac.at)
******************************
[1] BACKGROUND
From writing utilities MIDI2TXT and TXT2MIDI I got some knowledge
of midi file format. Once a person on net searched for help on
reviving a defect midi. I had a look at it and found that the note
data seemed to be ok but the structure of the midi file was lost.
The number of midi tracks and the length field of most tracks were 0.
I measured the number of tracks and the length of each track and
edited the correct values with a binary hexadecimal editor into the
midifile. The file was totally rescued by very simple changes.
I found that this simple operations could be done very quickly by a
small computer program.
[2] FILES DESCRIPTION
MIDIFIX.EXE..........MSDOS executable fixes structure bugs in midifiles
MIDIFIX.DOC..........this file, showing usage of MIDIFIX.EXE
MIDIFIX.CPP..........C/C++ source code for midifix (DOS/UNIX)
only MIDIFIX.EXE is required to run program
[3] COPYRIGHT
MIDIFIX (c) 1995 was created by Guenter Nagler.
MIDIFIX is free and may be used as you wish with this one exception:
You may NOT charge any fee or derive any profit for distribution
of MIDIFIX. Thus, you may NOT sell or bundle MIDIFIX with any
product in a retail environment (shareware disk distribution, CD-ROM,
etc.) without permission of the author.
You may give MIDIFIX to your friends, upload it to a BBS, or ftp it to
another internet site, as long as you don't charge anything for it.
[4] DISCLAIMER
MIDIFIX was designed to fix simple structure bugs in midifiles.
It counts the number of tracks and updates the tracknumber field in header.
It searches beginning and end of tracks and updates the tracklength field
for each recognized track.
MIDIFIX does not check the contents of a track.
Use MIDIFIX at your own risk. Anything you do with MIDIFIX is your
responsibility, and not the author's. Any damage caused to any person,
computer, software, hardware, company, or business by running MIDIFIX
is your responsibility, and the author will not be liable.
If you don't understand these terms, or are not sure of something, or
are afraid something bad might come of using MIDIFIX, don't use it!
You are here forewarned.
[5] INSTALLATION
[MSDOS]
Simply copy MIDIFIX.EXE in a directory that is in your path.
When you start the program without arguments
C:\> MIDIFIX
you should get the usage text (see next section)
[UNIX]
compile sources with your C++ compiler (e.g. GNU Compiler g++):
g++ -o midifix midifix.cpp
and run program
$ midifix
[6] USAGE
usage: MIDIFIX [-tracksonly] filename.mid [result.mid]
-tracksonly check and repair only track headers
if output filename is not given and changes are necessary then
output will be written to midifix.mid
The parameters in brackets [...] are optional.
The program will comment all changes done to the file.
Warning: The result files are overwritten without warning!
[7] OUTPUT MESSAGES
* file.mid: not a midifile (missing MThd)
Maybe this file never intended to be of MIDI file format?
A MIDI file must begin with 4 characters MThd.
midifix searches in the source file for this header.
* length of header updated
The length of a header is normally 6 bytes. For some reason
the length information does not match this value.
* length of track 1 updated
The length of a track did not match the number of bytes between
character sequence MTrk of track 1 and MTrk of track 2 or end of file.
* 1 track missing
the midi file is truncated and the original correct version of the file
contained 1 track more than now.
* 2 new tracks found
the midi file contains a too small track count value.
* number of tracks updated: 6
the number of tracks in trackcount field of header did not match the
number of tracks found in midifile (6 Tracks).
The value 6 is written into trackcount field.
* remove garbage at end of midi (1 byte)
The midifile contained invalid characters at the end of the file.
Normally a midi player/sequencer should ignore these bytes but some
do not accept the midi files. The characters are removed from the file.
* removing incomplete midi command
Warning: 2 bytes lost
When a track is truncated sometimes updating of track length does not
help. Commands that are incomplete are deleted at end of a track.
An end of track command is automatically added to track if last command
is not an end command.
* version 1 track contains different channel commands.
setting channel to 6
In a version 1 midi file the tracks should only contain midi commands
that are of same channel (and optionally not channel depending commands).
The first channel depending command sets the channel of track.
(This could also be caused by missing bytes in midi file so that
time values and commands are misinterpretated. Such errors cannot be
fixed by midifix)
[8] SUGGESTIONS / COMMENTS / BUG REPORTS / QUESTIONS
WWW: http://hgiicm.tu-graz.ac.at/Cpub
contains all my dos/unix midi programs
EMAIL: gnagler@ihm.tu-graz.ac.at
[9] CHANGES
v1.0 to v1.1:
* removing garbage bytes (bytes behind end command of last track)
* minor changes of file io to increase unix compatibility.
v1.1 to v1.2:
* writing result into new file (no changes are done in original file)
* checking midi commands (shows problems that cannot be repaired by midifix)
* removing truncated midi commands at end of tracks
* midi song searched in source file (does not need to be at beginning of file).
(that means: *.rmi files and macintosh midi files can be corrected to
standard midi files).
v1.2 to v1.3:
* handling files/archives containing multiple midi files, writing extra midi
files to separate files
* removes garbage bytes at end of a track (data between end of track and
following track)
* fixed bug: program allowed fixing of midifix.mid itself and destroyed it.
* Instead of multichannel error correction in version 1 midi files only
single warning per track and channels are not changed.
v1.3 to v1.4:
* added option -tracksonly to repair only track headers
(find midi tracks and their real length)
* fixed a bug that produced a warning about lost bytes where no byte was
really lost.
* converting midi files that begin with "SNio" instead of "MThd"